local skel = fk.CreateSkill {
  name = "lb_zero__jixing",
  tags = { Skill.Compulsory, Skill.Switch },
  max_branches_use_time = {
    ["round"] = {
      [Player.HistoryRound] = 1
    },
  }
}

Fk:loadTranslationTable {
  ["lb_zero__jixing"] = "疾星",
  [":lb_zero__jixing"] = "<b>锁定技</b>，<b>转换技</b>，你使用转化【杀】无距离限制，" ..
      "阳：你点数为奇数的手牌视为【杀】，且可在不因此技能使用牌时使用之；" ..
      "阴：你点数为偶数的手牌视为【杀】，且可在成为牌的目标时使用之；" ..
      "每轮限一次，当你受到伤害或不因使用失去手牌后，你可摸一张牌并转换〖疾星〗。",

  [":lb_zero__jixing_yang"] = "<b>锁定技</b>，<b>转换技</b>，你使用转化【杀】无距离限制，" ..
      "<font color=\"#E0DB2F\">阳：你点数为奇数的手牌视为【杀】，且可在不因此技能使用牌时使用之；</font>" ..
      "阴：你点数为偶数的手牌视为【杀】，且可在成为牌的目标时使用之；" ..
      "每轮限一次，当你受到伤害或不因使用失去手牌后，你可摸一张牌并转换〖疾星〗。",
  [":lb_zero__jixing_yin"] = "<b>锁定技</b>，<b>转换技</b>，你使用转化【杀】无距离限制，" ..
      "阳：你点数为奇数的手牌视为【杀】，且可在不因此技能使用牌时使用之；" ..
      "<font color=\"#E0DB2F\">阴：你点数为偶数的手牌视为【杀】，且可在成为牌的目标时使用之；</font>" ..
      "每轮限一次，当你受到伤害或不因使用失去手牌后，你可摸一张牌并转换〖疾星〗。",

  ["#lb_zero__jixing"] = "疾星：你可以使用一张因〖疾星〗转化的【杀】",
  ["#lb_zero__jixing-draw"] = "疾星：你可以摸一张牌并转换〖疾星〗",

  ["$lb_zero__jixing1"] = "It’s show time!",
  ["$lb_zero__jixing2"] = "不用着急，人人有份！",
  ["$lb_zero__jixing3"] = "星辉，在此闪耀！",
}

skel:addEffect(fk.CardUsing, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and table.contains(data.card.skillNames, skel.name)
  end,
  on_use = function(self, event, target, player, data)
  end,
})

skel:addEffect(fk.CardUsing, {
  --anim_type = "offensive",
  --is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and player:getSwitchSkillState(skel.name) == fk.SwitchYang and
    not player:isKongcheng() and not table.contains(data.card.skillNames, skel.name)
  end,
  on_trigger = function (self, event, target, player, data)
    local room = player.room
    local cards = table.filter(player:getCardIds("h"), function(id)
      return Fk:getCardById(id).number % 2 ~= 0
    end)
    room:askToUseVirtualCard(player, {
      name = "slash",
      card_filter = {
        n = 1,
        cards = cards,
      },
      skill_name = skel.name,
      prompt = "#lb_zero__jixing",
    })
  end,
  --[[
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local cards = table.filter(player:getCardIds("h"), function(id)
      return Fk:getCardById(id).number % 2 ~= 0
    end)
    local use = room:askToUseVirtualCard(player, {
      name = "slash",
      card_filter = {
        n = 1,
        cards = cards,
      },
      skill_name = skel.name,
      prompt = "#lb_zero__jixing",
      cancelable = true,
      skip = true,
    })
    if use then
      event:setCostData(self, { use = use })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local use = (event:getCostData(self) or {}).use
    if use then
      player.room:useCard(use)
    end
  end,
  --]]
})

skel:addEffect(fk.TargetConfirming, {
  --anim_type = "offensive",
  --is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and player:getSwitchSkillState(skel.name) == fk.SwitchYin and not player:isKongcheng()
  end,
  on_trigger = function (self, event, target, player, data)
    local room = player.room
    local cards = table.filter(player:getCardIds("h"), function(id)
      return Fk:getCardById(id).number % 2 == 0
    end)
    room:askToUseVirtualCard(player, {
      name = "slash",
      card_filter = {
        n = 1,
        cards = cards,
      },
      skill_name = skel.name,
      prompt = "#lb_zero__jixing",
    })
  end,
  --[[
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local cards = table.filter(player:getCardIds("h"), function(id)
      return Fk:getCardById(id).number % 2 == 0
    end)
    local use = room:askToUseVirtualCard(player, {
      name = "slash",
      card_filter = {
        n = 1,
        cards = cards,
      },
      skill_name = skel.name,
      prompt = "#lb_zero__jixing",
      cancelable = true,
      skip = true,
    })
    if use then
      event:setCostData(self, { use = use })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:useCard(event:getCostData(self).use)
  end,
  --]]
})

skel:addEffect(fk.Damaged, {
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and
        player:usedSkillTimes(skel.name, Player.HistoryRound, "round") == 0
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, { skill_name = skel.name, prompt = "#lb_zero__jixing-draw" })
  end,
  on_use = function(self, event, target, player, data)
    player:addSkillBranchUseHistory(skel.name, "round")
    player:drawCards(1, skel.name)
  end,
})

skel:addEffect(fk.AfterCardsMove, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) and player:usedSkillTimes(skel.name, Player.HistoryRound, "round") == 0 then
      for _, move in ipairs(data) do
        if move.from == player and move.moveReason ~= fk.ReasonUse and table.find(move.moveInfo, function(info)
              return info.fromArea == Card.PlayerHand
            end) then
          return true
        end
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, { skill_name = skel.name, prompt = "#lb_zero__jixing-draw" })
  end,
  on_use = function(self, event, target, player, data)
    player:addSkillBranchUseHistory(skel.name, "round")
    player:drawCards(1, skel.name)
  end,
})

skel:addEffect("filter", {
  mute = true,
  card_filter = function(self, card, player, isJudgeEvent)
    return player:hasSkill(skel.name) and table.contains(player:getCardIds("h"), card.id) and
        (
          (player:getSwitchSkillState(skel.name) == fk.SwitchYang and (card.number % 2 ~= 0)) or
          (player:getSwitchSkillState(skel.name) == fk.SwitchYin and (card.number % 2 == 0))
        )
  end,
  view_as = function(self, player, card)
    local slash = Fk:cloneCard("slash", card.suit, card.number)
    slash.skillName = skel.name
    return slash
  end,
})

skel:addEffect("targetmod", {
  bypass_distances = function(self, player, skill, card, to)
    return player:hasSkill(skel.name) and card.trueName == "slash" and card and
        (card:isConverted() or #card.skillNames > 0)
  end,
})


return skel
